Skip to content

test(coverage): backfill toward >=80% SonarCloud new-code coverage#59

Merged
aksOps merged 1 commit into
mainfrom
test/coverage-backfill-sonar
Apr 23, 2026
Merged

test(coverage): backfill toward >=80% SonarCloud new-code coverage#59
aksOps merged 1 commit into
mainfrom
test/coverage-backfill-sonar

Conversation

@aksOps
Copy link
Copy Markdown
Contributor

@aksOps aksOps commented Apr 23, 2026

Goal

Raise SonarCloud's new_coverage metric with 112 new meaningful tests
against the highest-uncovered-line files flagged by local JaCoCo.

Note on the premise: the task cited new_coverage = 70.7% vs 80% threshold, but SonarCloud currently reports new_coverage = 83.74%
on main (quality gate OK). The 70.7% number matches PR #53's own
decoration, not the branch metric. This PR still adds the requested
tests to strengthen the margin and cover paths flagged as risky by
local JaCoCo.

Local JaCoCo deltas

Project-level:

Metric Before After Delta
LINE 89.31% 89.94% +0.63pp
BRANCH 71.31% 72.63% +1.32pp
Covered lines 16,992 17,112 +120

Per-file (line coverage, highest-impact first):

File Before After
config/unified/EnvVarOverlay.java 52.9% 100.0%
detector/jvm/java/AzureMessagingDetector.java 76.6% 100.0%
detector/jvm/java/AzureFunctionsDetector.java 79.2% 100.0%
intelligence/extractor/LanguageEnricher.java 74.6% 88.1%
detector/jvm/java/ModuleDepsDetector.java 78.9% 88.0%
detector/jvm/java/ConfigDefDetector.java 74.6% 75.4%
detector/typescript/ExpressRouteDetector.java 38.3% 38.3%

Test count

Before: 3,278 tests. After: 3,390 (+112 new tests).

What was NOT covered and why

  • ExpressRouteDetector.detectWithAst (50 dead lines) — AbstractTypeScriptDetector.detect()
    routes unconditionally to detectWithRegex, so the AST override is
    never invoked. Listed as follow-up.
  • ConfigDefDetector.detectWithRegexAbstractJavaParserDetector.parse()
    recovers from most invalid Java, so the regex fallback is not
    reliably reachable without reflection. Kept narrow AST-branch
    coverage; flagged as a cleanup candidate.
  • ModuleDepsDetector.detectGradleSettings (~17 lines) — the dispatch
    chain checks .endsWith(".gradle") before .endsWith("settings.gradle"),
    so any filename matching the latter has already been routed to
    detectGradle. The detectGradleSettings branch is unreachable from
    detect(). Flagged as a follow-up.

Bugs observed while writing tests (NOT fixed here)

Per task rules, these are filed as follow-ups:

  1. ModuleDepsDetector.detect() dispatch-order bug: detectGradleSettings()
    is unreachable because the .gradle suffix check shadows the
    settings.gradle check.
  2. ExpressRouteDetector.detectWithAst() is dead code — never invoked
    because the base AbstractTypeScriptDetector.detect() doesn't call
    the AST variant.
  3. RepositoryIdentityTest has two pre-existing environment-dependent
    failures on main (resolve_gitRepoWithCommit_commitShaPresent,
    resolve_detachedHead_branchIsNull). Unrelated to this PR; build
    also fails on unmodified main with these same two assertions.

How to verify

mvn -B clean test -DskipITs=true
mvn -B -o jacoco:report
xdg-open target/site/jacoco/index.html

Test run result: 3,390 tests, only the two pre-existing
RepositoryIdentityTest failures remain (present on main too).

Hard rules compliance

  • Zero changes in src/main (test-only PR)
  • No @Disabled, no assumeTrue(false), no flaky constructs
  • No Thread.sleep, no timing dependence
  • Determinism assertions in every detector test (per CLAUDE.md convention)
  • No touches to generated code, no touches to @Configuration classes

🤖 Generated with Claude Code

Adds 112 new tests across 6 new classes targeting high-uncovered-line
files flagged by SonarCloud + local JaCoCo. Net project LINE coverage
moved 89.31% -> 89.94% (+120 covered lines, +0.63pp).

Per-file deltas (line coverage):
  EnvVarOverlay.java                     52.9% -> 100.0%  (+47.1pp)
  AzureMessagingDetector.java            76.6% -> 100.0%  (+23.4pp)
  AzureFunctionsDetector.java            79.2% -> 100.0%  (+20.8pp)
  LanguageEnricher.java                  74.6% ->  88.1%  (+13.5pp)
  ModuleDepsDetector.java                78.9% ->  88.0%  (+9.1pp)
  ConfigDefDetector.java                 74.6% ->  75.4%  (+0.8pp)

Test additions:
  EnvVarOverlayExtendedTest            — 19 tests, all switch cases,
                                          neo4j/mcp/observability overlays,
                                          splitCsv edge cases, determinism
  AzureMessagingDetectorTest           — 21 tests (new file), SB + EH
                                          clients named + generic fallbacks
  AzureFunctionsDetectorTest           — 15 tests (new file), every
                                          trigger branch: HTTP, SB queue/topic,
                                          Event Hub, Timer, CosmosDB, unknown
  ConfigDefDetectorTest                — 18 tests (new file), AST branches
                                          for Kafka ConfigDef / @value /
                                          @ConfigurationProperties with
                                          deduplication and discriminator
                                          guard checks
  ModuleDepsDetectorTest               — 18 tests (new file), Maven +
                                          Gradle (Groovy) + dep extraction
  LanguageEnricherExtendedTest         — 14 tests, file_type skip list,
                                          missing file handling, null
                                          filePath, minified-file heuristic,
                                          fqn/id registry, mjs/cjs/pyw

Follow-up (bugs observed while testing, NOT fixed here):
  - ModuleDepsDetector dispatch order: .gradle ends-with check matches
    settings.gradle before the dedicated settings.gradle branch, leaving
    detectGradleSettings() unreachable via detect().
  - ExpressRouteDetector defines detectWithAst but the base detect()
    in AbstractTypeScriptDetector routes only to detectWithRegex, so
    the AST method is currently dead code.
  - RepositoryIdentityTest has two pre-existing env-dependent failures
    on main (resolve_gitRepoWithCommit_commitShaPresent,
    resolve_detachedHead_branchIsNull) - unrelated to this change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@aksOps aksOps merged commit dd8adaa into main Apr 23, 2026
9 checks passed
@aksOps aksOps deleted the test/coverage-backfill-sonar branch April 26, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant